package aidturith.ihm.component;

import java.util.ArrayList;

import javax.swing.JTable;
import javax.swing.table.TableModel;

public class Table extends JTable {

	private static final long serialVersionUID = 1L;

	private ArrayList<Boolean> isEditable = new ArrayList<Boolean>();

	public Table(TableModel model) {
		super(model);
	}

	//  Returning the Class of each column will allow different
	//  renderers to be used based on Class
	@Override
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Class getColumnClass(int column) {
		return getValueAt(0, column).getClass();
	}

	//  Les deux premières colonnes ne sont pas modifiables
	@Override
	public boolean isCellEditable(int row, int column) {
		int modelColumn = convertColumnIndexToModel(column);
		return getIsEditable().get(modelColumn);
		//return ((modelColumn == 1) || (modelColumn == 2) || (modelColumn == 3) || (modelColumn == 4)) ? false : true;
		//return true;
	}

	public ArrayList<Boolean> getIsEditable() { return isEditable; }
	public void setIsEditable(ArrayList<Boolean> isEditable) { this.isEditable = isEditable; }

}
